<template>
	<view class="wrap">
		<view class="top" />
		<view class="content">
			<view class="title">欢迎登录</view>
		</view>
		<view class="buttom">
			<view class="loginType">
				<view class="pwd item" id="pwd">
					<view class="icon">
						<u-icon size="40" name="lock-fill" color="rgb(22,22,64)"></u-icon>
					</view>
					密码
				</view>
				<view class="wechat item" @click="wxLogin">
					<view class="icon">
						<u-icon
							size="40"
							name="weixin-fill"
							color="rgb(83,194,64)"
						></u-icon>
					</view>
					微信
				</view>
				<view class="code item" id="smscode">
					<view class="icon">
						<u-icon size="40" name="chat" color="rgb(17,183,233)"></u-icon>
					</view>
					验证码
				</view>
			</view>
			<view class="hint">
				登录代表同意
				<text class="link">用户协议、隐私政策，</text>
				并授权使用您的账号信息（如昵称、头像、收获地址）以便您统一管理
			</view>
		</view>
	</view>
</template>

<script lang="ts" setup>
let tel = ref("");
let loginType = ref("");

const submit = () => {
	if (uni.$u.test.mobile(tel.value)) {
		uni.$u.route({
			url: "pages/template/login/code"
		});
	}
};

const wxLogin = () => {
	uni.login({
		provider: "weixin",
		success: function (loginRes) {
			// 登录成功
			uni.getUserInfo({
				provider: "weixin",
				success: function (info) {
					console.log(info);
					// 获取用户信息成功, info.authResult保存用户信息
				}
			});
		},
		fail: function (err) {
			// 登录授权失败
			// err.code是错误码
		}
	});
};
</script>

<style lang="scss" scoped>
.wrap {
	font-size: 28rpx;
	.content {
		width: 600rpx;
		margin: 80rpx auto 0;

		.title {
			text-align: left;
			font-size: 60rpx;
			font-weight: 500;
			margin-bottom: 100rpx;
		}
		input {
			text-align: left;
			margin-bottom: 10rpx;
			padding-bottom: 6rpx;
		}
		.tips {
			color: $u-info;
			margin-bottom: 60rpx;
			margin-top: 8rpx;
			font-size: 12px;
		}
		.getCaptcha {
			background-color: rgb(253, 243, 208);
			color: $u-tips-color;
			border: none;
			font-size: 30rpx;
			padding: 12rpx 0;

			&::after {
				border: none;
			}
		}
		.alternative {
			color: $u-tips-color;
			display: flex;
			justify-content: space-between;
			margin-top: 30rpx;
		}
	}
	.buttom {
		.loginType {
			display: flex;
			padding: 0 130rpx 50rpx 130rpx;
			justify-content: space-between;
			.item {
				display: flex;
				flex-direction: column;
				align-items: center;
				color: $u-content-color;
				font-size: 28rpx;
			}
		}

		.hint {
			padding: 20rpx 40rpx;
			font-size: 20rpx;
			color: $u-tips-color;

			.link {
				color: $u-warning;
			}
		}
	}
}
</style>
